/**
 * 
 */
package sg.edu.nus.iss.team8s.vmcs.builder;

import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import sg.edu.nus.iss.team8s.vmcs.Listener.CoinInputListener;
import sg.edu.nus.iss.team8s.vmcs.Listener.DrinkSelectionListener;
import sg.edu.nus.iss.team8s.vmcs.beans.Coin;
import sg.edu.nus.iss.team8s.vmcs.beans.DrinksBrand;
import sg.edu.nus.iss.team8s.vmcs.beans.StoreItem;
import sg.edu.nus.iss.team8s.vmcs.beans.StoreObject;
import sg.edu.nus.iss.team8s.vmcs.cache.CashStore;
import sg.edu.nus.iss.team8s.vmcs.cache.DrinksStore;
import sg.edu.nus.iss.team8s.vmcs.commons.CommonsFactory;
import sg.edu.nus.iss.team8s.vmcs.commons.Constant;
import sg.edu.nus.iss.team8s.vmcs.control.CoinReceiver;
import sg.edu.nus.iss.team8s.vmcs.control.DispenseController;
import sg.edu.nus.iss.team8s.vmcs.control.TransactionController;

/**
 * @author Wang Shi Jie
 *
 */
public class CustomerBuilder implements UIBuilder {
	public static final String CUSTOMER_PANEL_TITLE = "VIMTO Soft Drink Dispenser";
	public static final String ENTER_COIN = "Enter Coins Here";
	public static final String CENT_5 = "5c";
	public static final String CENT_10  = "10 c";
	public static final String CENT_20 = "20 c";
	public static final String CENT_50 = "50 c";
	public static final String CENT_100 = "$ 1";
	public static final String CENT_INVALID = "Invalid";
	public static final String INVALID_COIN = "Invalid Coin";
	public static final String TOTAL_MONEY = "Total Money Inserted:";
	public static final String DRINK_STATUS = "Not in Stock";
	public static final String CHANGE_STATUS_MESSAGE = "No Change Available";
	public static final String TERMINATE = "Terminate and Return Cash";
	public static final String COLLECT_COIN = "Collect Coins:";
	public static final String COLLECT_CAN = "Collect Can Here:";
	public static final String ZERO_CENT = "0";
	public static final String NO_CAN = "NO CAN";
	
	/*private CustomerPanel customerPanel;*/
	private Panel customerPanel;
	private TransactionController tranController;
	/*private CoinReceiver coinReceiver;*/
	/*private DispenseController dispenseController;*/
	private Button[] btnListCoin;
	private Button[] btnListDrink;
	private Label[] lblListDrinkPrice;
	private Label[] lblListStoreStatus;
	
	public CustomerBuilder(){
		/*customerPanel = new CustomerPanel();*/
		customerPanel = new Panel();
		FlowLayout layout = new FlowLayout();
		layout.setVgap(0);
		customerPanel.setLayout(layout);
		customerPanel.setPreferredSize(new Dimension(Constant.PANEL_WIDTH, 600));
		tranController = TransactionController.getInstance(); 
		/*coinReceiver = CoinReceiver.getInstance();*/
		/*dispenseController = DispenseController.getInstance();*/
	}

	public void buildTitlePanel(){
		Panel p = new Panel();
		p.setPreferredSize(new Dimension(Constant.PANEL_WIDTH, 60));
		//p.setBackground(Color.YELLOW);
		p.setBackground(Constant.DEFAULT_BACKGROUND_COLOR);
		
		Label title = CommonsFactory.getInstance().getLabel(Constant.LABEL_TITLE, CustomerBuilder.CUSTOMER_PANEL_TITLE);
		title.setFont(new Font("Times New Roman", Font.BOLD, 20));
		p.add(title);
		
		//panelUI.add(p);
		//customerPanel.setTitlePanel(p);
		customerPanel.add(p);
	}
	
	public void buildInputPanel(){
		int GAPLENGTH = 0;
		Panel p = new Panel();
		p.setPreferredSize(new Dimension(Constant.PANEL_WIDTH, 170));
		p.setBackground(Constant.DEFAULT_BACKGROUND_COLOR);
		//p.setBackground(Color.ORANGE);
		p.setLayout(null);
		
		Label enterCoin = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_NORMAL_BGRD, CustomerBuilder.ENTER_COIN);
		enterCoin.setPreferredSize(new Dimension(150, 25));
		enterCoin.setFont(new Font("Times New Roman", Font.BOLD, 12));
		
		Insets insets = p.getInsets();
		enterCoin.setPreferredSize(new Dimension(120, 25));
		Dimension d = enterCoin.getPreferredSize();
		enterCoin.setBounds(1 + insets.left, 0 + insets.top, d.width, d.height);
		
		CashStore cashStore = CashStore.getInstance();
		btnListCoin = new Button[cashStore.getStoreSize()+1];
		
		for(int i =0;i<cashStore.getStoreSize();i++){			
			StoreItem item = cashStore.getItem(i);
			StoreObject obj = item.getContent();
			
			Button btnCoin = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, obj.getName());
			btnCoin.setName(obj.getClass().getName()+ String.valueOf(i));
			btnCoin.setPreferredSize(new Dimension(59,40));
			btnCoin.setEnabled(false);
			
			d = btnCoin.getPreferredSize();
			btnCoin.setBounds(0 + GAPLENGTH + insets.left, 27 + insets.top, d.width, d.height);
			
			btnCoin.addActionListener(new CoinInputListener(((Coin)obj).getWeight()));
			
			btnListCoin[i] = btnCoin;
			
			p.add(btnCoin);
			
			GAPLENGTH += 60;
		}
		
		/*Button c5 = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, CustomerBuilder.CENT_5);
		c5.setPreferredSize(new Dimension(59,40));
		Button c10 = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, CustomerBuilder.CENT_10);
		Button c20 = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, CustomerBuilder.CENT_20);
		Button c50 = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, CustomerBuilder.CENT_50);
		Button c100 = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, CustomerBuilder.CENT_100);*/
		Button cInvalid = CommonsFactory.getInstance().getButton(Constant.BUTTON_SMALL, CustomerBuilder.CENT_INVALID);
		cInvalid.setPreferredSize(new Dimension(59,40));
		cInvalid.setEnabled(false);
		tranController.setCoinInputBox(btnListCoin);
		btnListCoin[cashStore.getStoreSize()] = cInvalid;
		
		Label invalidCoin = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.INVALID_COIN);
		
		Label totalMoney = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_NORMAL_BGRD, CustomerBuilder.TOTAL_MONEY);
		Label totalMoneyValue = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_LONGER, CustomerBuilder.ZERO_CENT);
		
		
		//enterCoin.setBackground(Color.GRAY);
		
		
		/*d = c5.getPreferredSize();
		c5.setBounds(1 + insets.left, 26 + insets.top, d.width, d.height);
		
		d = c10.getPreferredSize();
		c10.setBounds(60 + insets.left, 27 + insets.top, d.width, d.height);
		
		d = c20.getPreferredSize();
		c20.setBounds(120 + insets.left, 27 + insets.top, d.width, d.height);
		
		d = c50.getPreferredSize();
		c50.setBounds(180 + insets.left, 27 + insets.top, d.width, d.height);
		
		d = c100.getPreferredSize();
		c100.setBounds(240 + insets.left, 27 + insets.top, d.width, d.height);*/
		
		d = cInvalid.getPreferredSize();
		cInvalid.setBounds(300 + insets.left, 27 + insets.top, d.width, d.height);
		
		invalidCoin.setPreferredSize(new Dimension(100, 20));
		d = invalidCoin.getPreferredSize();
		invalidCoin.setAlignment(Label.CENTER);
		invalidCoin.setFont(new Font("Times New Roman", Font.BOLD, 12));
		invalidCoin.setForeground(Color.WHITE);
		invalidCoin.setBounds(130 + insets.left, 80 + insets.top, d.width, d.height);
		
		totalMoney.setPreferredSize(new Dimension(130, 25));
		//totalMoney.setAlignment(Label.RIGHT);
		//totalMoney.setBackground(Color.GREEN);
		totalMoney.setFont(new Font("Times New Roman", Font.BOLD, 12));
		d = totalMoney.getPreferredSize();
		totalMoney.setBounds(90 + insets.left, 125 + insets.top, d.width, d.height);
		
		totalMoneyValue.setPreferredSize(new Dimension(50, 20));
		totalMoneyValue.setForeground(Color.YELLOW);
		totalMoneyValue.setAlignment(Label.CENTER);
		totalMoneyValue.setFont(new Font("Monospaced", Font.PLAIN, 12));
		d = totalMoneyValue.getPreferredSize();
		totalMoneyValue.setBounds(220 + insets.left, 125 + insets.top, d.width, d.height);
		
		tranController.setTotalMoneyValue(totalMoneyValue);
		
		p.add(enterCoin);
		/*p.add(c5);
		p.add(c10);
		p.add(c20);
		p.add(c50);
		p.add(c100);*/
		p.add(cInvalid);
		p.add(invalidCoin);
		p.add(totalMoney);
		p.add(totalMoneyValue);
		
		/*customerPanel.setInputPanel(p);
		customerPanel.setFiveCent(c5);
		customerPanel.setTenCent(c10);
		customerPanel.setTwentyCent(c20);
		customerPanel.setFiftyCent(c50);
		customerPanel.setOneDollar(c100);
		customerPanel.setInvalid(cInvalid);
		customerPanel.setInvalidCoin(invalidCoin);
		customerPanel.setTotalMoneyValue(totalMoneyValue);*/
		customerPanel.add(p);
		//panelUI.add(p);
	}
	
	public void buildDisplayPanel(){
		int GAPLENGTH = 0;
		Panel p = new Panel();
		p.setPreferredSize(new Dimension(Constant.PANEL_WIDTH, 170));
		p.setBackground(Constant.DEFAULT_BACKGROUND_COLOR);
		//p.setBackground(Color.PINK);
		p.setLayout(null);
		
		Insets insets = p.getInsets();
		Dimension d = new Dimension();
		DrinksStore drinkStore = DrinksStore.getInstance();
		btnListDrink = new Button[drinkStore.getStoreSize()];
		lblListDrinkPrice = new Label[drinkStore.getStoreSize()]; 
		lblListStoreStatus = new Label[drinkStore.getStoreSize()];
		for(int i =0;i<drinkStore.getStoreSize();i++){
			StoreItem item = drinkStore.getItem(i);
			DrinksBrand obj = (DrinksBrand)item.getContent();
			
			Button btnBrank = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, obj.getName());
			//btnBrank.setName(obj.getClass().getName()+ String.valueOf(i));
			btnBrank.setPreferredSize(new Dimension(125, 34));
			btnBrank.setFont(new Font("Times New Roman", Font.BOLD, 12));
			btnBrank.setBackground(Color.WHITE);
			btnBrank.addActionListener(new DrinkSelectionListener(i));
			
			System.out.println("brand name:" + obj.getName());
			System.out.println("brand qty:" + item.getQuantity());
			
			if(item.getQuantity()<=0)
				btnBrank.setEnabled(false);
			else
				btnBrank.setEnabled(true);
			
			Label lblPrice = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_SHORTER, String.valueOf(obj.getPrice()));
			//lblPrice.setName("lbl"+obj.getClass().getName()+ String.valueOf(i));
			lblPrice.setPreferredSize(new Dimension(50, 20));
			lblPrice.setFont(new Font("Times New Roman", Font.BOLD, 12));
			lblPrice.setForeground(Color.YELLOW);
			lblPrice.setAlignment(1);
			
			Label lblStatus = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD,CustomerBuilder.DRINK_STATUS);
			lblStatus.setPreferredSize(new Dimension(100, 20));
			lblStatus.setFont(new Font("Times New Roman", Font.BOLD, 12));
			if(item.getQuantity()>0)
				lblStatus.setForeground(Color.GRAY);
			else
				lblStatus.setForeground(Color.WHITE);
			lblStatus.setAlignment(Label.CENTER);
			
			d = btnBrank.getPreferredSize();
			btnBrank.setBounds(0 + insets.left, 0 + GAPLENGTH + insets.top, d.width, d.height);
			
			d = lblPrice.getPreferredSize();
			lblPrice.setBounds(165 + insets.left, 7 + GAPLENGTH + insets.top, d.width, d.height);
			
			d = lblStatus.getPreferredSize();
			lblStatus.setBounds(255 + insets.left, 7 + GAPLENGTH + insets.top, d.width, d.height);
			
			btnListDrink[i] = btnBrank;
			lblListDrinkPrice[i] = lblPrice;
			lblListStoreStatus[i] = lblStatus;
			
			tranController.setDrinkSelectBtn(btnListDrink);
			tranController.setDrinkPrice(lblListDrinkPrice);
			tranController.setStoreStatus(lblListStoreStatus);
			
			p.add(btnBrank);
			p.add(lblPrice);
			p.add(lblStatus);
			
			GAPLENGTH += 34;
		}
		customerPanel.add(p);
		/*Button button1 = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, "");
		button1.setPreferredSize(new Dimension(125, 34));
		button1.setFont(new Font("Times New Roman", Font.BOLD, 12));
		button1.setBackground(Color.WHITE);
		Button button2 = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, "");
		button2.setPreferredSize(new Dimension(125, 34));
		button2.setFont(new Font("Times New Roman", Font.BOLD, 12));
		button2.setBackground(Color.WHITE);
		Button button3 = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, "");
		button3.setPreferredSize(new Dimension(125, 34));
		button3.setFont(new Font("Times New Roman", Font.BOLD, 12));
		button3.setBackground(Color.WHITE);
		Button button4 = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, "");
		button4.setPreferredSize(new Dimension(125, 34));
		button4.setFont(new Font("Times New Roman", Font.BOLD, 12));
		button4.setBackground(Color.WHITE);
		Button button5 = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, "");
		button5.setPreferredSize(new Dimension(125, 34));
		button5.setFont(new Font("Times New Roman", Font.BOLD, 12));
		button5.setBackground(Color.WHITE);
		
		Label price1 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_SHORTER, "");
		price1.setPreferredSize(new Dimension(50, 20));
		price1.setFont(new Font("Times New Roman", Font.BOLD, 12));
		Label price2 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_SHORTER, "");
		price2.setPreferredSize(new Dimension(50, 20));
		price2.setFont(new Font("Times New Roman", Font.BOLD, 12));
		Label price3 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_SHORTER, "");
		price3.setPreferredSize(new Dimension(50, 20));
		price3.setFont(new Font("Times New Roman", Font.BOLD, 12));
		Label price4 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_SHORTER, "");
		price4.setPreferredSize(new Dimension(50, 20));
		price4.setFont(new Font("Times New Roman", Font.BOLD, 12));
		Label price5 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_SHORTER, "");
		price5.setPreferredSize(new Dimension(50, 20));
		price5.setFont(new Font("Times New Roman", Font.BOLD, 12));
		
		Label status1 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.DRINK_STATUS);
		status1.setPreferredSize(new Dimension(100, 20));
		status1.setFont(new Font("Times New Roman", Font.BOLD, 12));
		status1.setForeground(Color.GRAY);
		status1.setAlignment(Label.CENTER);
		Label status2 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.DRINK_STATUS);
		status2.setPreferredSize(new Dimension(100, 20));
		status2.setFont(new Font("Times New Roman", Font.BOLD, 12));
		status2.setForeground(Color.GRAY);
		status2.setAlignment(Label.CENTER);
		Label status3 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.DRINK_STATUS);
		status3.setPreferredSize(new Dimension(100, 20));
		status3.setFont(new Font("Times New Roman", Font.BOLD, 12));
		status3.setForeground(Color.GRAY);
		status3.setAlignment(Label.CENTER);
		Label status4 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.DRINK_STATUS);
		status4.setPreferredSize(new Dimension(100, 20));
		status4.setFont(new Font("Times New Roman", Font.BOLD, 12));
		status4.setForeground(Color.WHITE);
		status4.setAlignment(Label.CENTER);
		Label status5 = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.DRINK_STATUS);
		status5.setPreferredSize(new Dimension(100, 20));
		status5.setFont(new Font("Times New Roman", Font.BOLD, 12));
		status5.setForeground(Color.GRAY);
		status5.setAlignment(Label.CENTER);
				
		Insets insets = p.getInsets();
		//button1.setPreferredSize(new Dimension(120, 25));
		//enterCoin.setBackground(Color.GRAY);
		Dimension d = button1.getPreferredSize();
		button1.setBounds(0 + insets.left, 0 + insets.top, d.width, d.height);
		
		d = price1.getPreferredSize();
		price1.setBounds(165 + insets.left, 7 + insets.top, d.width, d.height);
		
		d = status1.getPreferredSize();
		status1.setBounds(255 + insets.left, 7 + insets.top, d.width, d.height);
		
		d = button2.getPreferredSize();
		button2.setBounds(0 + insets.left, 34 + insets.top, d.width, d.height);
		
		d = price2.getPreferredSize();
		price2.setBounds(165 + insets.left, 41 + insets.top, d.width, d.height);
		
		d = status2.getPreferredSize();
		status2.setBounds(255 + insets.left, 41 + insets.top, d.width, d.height);
		
		d = button3.getPreferredSize();
		button3.setBounds(0 + insets.left, 68 + insets.top, d.width, d.height);
		
		d = price3.getPreferredSize();
		price3.setBounds(165 + insets.left, 75 + insets.top, d.width, d.height);
		
		d = status3.getPreferredSize();
		status3.setBounds(255 + insets.left, 75 + insets.top, d.width, d.height);
		
		d = button4.getPreferredSize();
		button4.setBounds(0 + insets.left, 102 + insets.top, d.width, d.height);
		
		d = price4.getPreferredSize();
		price4.setBounds(165 + insets.left, 109 + insets.top, d.width, d.height);
		
		d = status4.getPreferredSize();
		status4.setBounds(255 + insets.left, 109 + insets.top, d.width, d.height);
		
		d = button5.getPreferredSize();
		button5.setBounds(0 + insets.left, 136 + insets.top, d.width, d.height);
		
		d = price5.getPreferredSize();
		price5.setBounds(165 + insets.left, 143 + insets.top, d.width, d.height);
		
		d = status5.getPreferredSize();
		status5.setBounds(255 + insets.left, 143 + insets.top, d.width, d.height);
		
		p.add(button1);
		p.add(price1);
		p.add(status1);
		p.add(button2);
		p.add(price2);
		p.add(status2);
		p.add(button3);
		p.add(price3);
		p.add(status3);
		p.add(button4);
		p.add(price4);
		p.add(status4);
		p.add(button5);
		p.add(price5);
		p.add(status5);
		
		Button[] buttons = new Button[]{button1, button2, button3, button4, button5};
		Label[] prices = new Label[]{price1, price2, price3, price4, price5};
		Label[] status = new Label[]{status1, status2, status3, status4, status5};
		
		customerPanel.setBrands(buttons);
		customerPanel.setPrices(prices);
		customerPanel.setStatus(status);
		customerPanel.setDisplayPanel(p);
		customerPanel.add(p);
		//panelUI.add(p);*/
	}
	
	public void buildStatusPanel(){
		Panel p = new Panel();
		p.setPreferredSize(new Dimension(Constant.PANEL_WIDTH, 200));
		p.setBackground(Constant.DEFAULT_BACKGROUND_COLOR);
		p.setLayout(null);
		
		Label changeStatus = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_RED_BGRD, CustomerBuilder.CHANGE_STATUS_MESSAGE);
		changeStatus.setPreferredSize(new Dimension(130, 20));
		changeStatus.setFont(new Font("Times New Roman", Font.BOLD, 12));
		changeStatus.setAlignment(Label.CENTER);
		changeStatus.setForeground(Color.GRAY);
		
		Button terminate = CommonsFactory.getInstance().getButton(Constant.BUTTON_BIG, CustomerBuilder.TERMINATE);
		terminate.setPreferredSize(new Dimension(180, 34));
		terminate.setFont(new Font("Times New Roman", Font.BOLD, 12));
		terminate.setBackground(Color.WHITE);
		
		Label collectCoin = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_NORMAL_BGRD, CustomerBuilder.COLLECT_COIN);
		collectCoin.setPreferredSize(new Dimension(130, 20));
		collectCoin.setFont(new Font("Times New Roman", Font.BOLD, 12));
		collectCoin.setAlignment(Label.RIGHT);
		
		Label collectCoinValue = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_LONGER, CustomerBuilder.ZERO_CENT);
		collectCoinValue.setPreferredSize(new Dimension(50, 20));
		collectCoinValue.setFont(new Font("Times New Roman", Font.PLAIN, 12));
		collectCoinValue.setAlignment(Label.CENTER);
		collectCoinValue.setForeground(Color.YELLOW);
		
		Label collectCan = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_NORMAL_BGRD, CustomerBuilder.COLLECT_CAN);
		collectCan.setPreferredSize(new Dimension(130, 20));
		//collectCan.setBackground(Color.GREEN);
		collectCan.setFont(new Font("Times New Roman", Font.BOLD, 12));
		collectCan.setAlignment(Label.RIGHT);		
		
		Label collectCanValue = CommonsFactory.getInstance().getLabel(Constant.LABEL_WITH_BLACK_BGRD_LONGER, CustomerBuilder.NO_CAN);
		collectCanValue.setPreferredSize(new Dimension(50, 20));
		collectCanValue.setFont(new Font("Times New Roman", Font.PLAIN, 12));
		collectCanValue.setAlignment(Label.CENTER);
		collectCanValue.setForeground(Color.YELLOW);
		
		tranController.setLabelCollectCanValue(collectCanValue);
		
		Insets insets = p.getInsets();
		Dimension d = changeStatus.getPreferredSize();
		changeStatus.setBounds(115 + insets.left, 10 + insets.top, d.width, d.height);
		
		d = terminate.getPreferredSize();
		terminate.setBounds(90 + insets.left, 45 + insets.top, d.width, d.height);
		
		d = collectCoin.getPreferredSize();
		collectCoin.setBounds(50 + insets.left, 94 + insets.top, d.width, d.height);
		
		d = collectCoinValue.getPreferredSize();
		collectCoinValue.setBounds(245 + insets.left, 94 + insets.top, d.width, d.height);
		
		d = collectCan.getPreferredSize();
		collectCan.setBounds(50 + insets.left, 139 + insets.top, d.width, d.height);
		
		d = collectCanValue.getPreferredSize();
		collectCanValue.setBounds(245 + insets.left, 139 + insets.top, d.width, d.height);
		
		tranController.setCollectCash(collectCoinValue);
		
		p.add(changeStatus);
		p.add(terminate);
		p.add(collectCoin);
		p.add(collectCoinValue);
		p.add(collectCan);
		p.add(collectCanValue);
		
		/*customerPanel.setStatusPanel(p);
		customerPanel.setChangeStatus(changeStatus);
		customerPanel.setTerminate(terminate);
		customerPanel.setCollectCoinValue(collectCoinValue);
		customerPanel.setCollectCanValue(collectCanValue);*/
		customerPanel.add(p);
		//panelUI.add(p);
	}
	
	public Panel getResult(){
		return this.customerPanel;
	}
	
	public static void main(String args[]){
		Frame f = new Frame();
		//f.setPreferredSize(new Dimension(300, 600));
		f.setTitle("VMCS - Customer Panel");
		f.setSize(new Dimension(Constant.PANEL_WIDTH, 600));
		f.setResizable(false);
		f.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
		
		UIBuilder uib = BuilderFactory.getInstance().getUIBuilder("customerUIBuilder");
		uib.buildTitlePanel();
		uib.buildInputPanel();
		uib.buildDisplayPanel();
		uib.buildStatusPanel();
		f.add(uib.getResult());
		f.setVisible(true);
	}
}
